package com.erp.myAdapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.TextView
import com.erp.bean.JijianBean
import com.erp.R
import com.erp.util.Myutil
import kotlinx.android.synthetic.main.lv_jijian_yuangong.view.*


/**
 * Created by Administrator on 2017/2/16/016.
 * 作者：刘洋
 */
class JijianYuangongAdapter(private val mlist: List<JijianBean.MembersBean>, private val mcontext: Context) : BaseAdapter() {
    private val minfalter: LayoutInflater = LayoutInflater.from(mcontext)

    override fun getCount(): Int {
        return mlist.size
    }

    override fun getItem(position: Int): JijianBean.MembersBean {
        return mlist[position]
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        var v : View
        val vh: ViewHolder
        if (convertView == null) {
            v = minfalter.inflate(R.layout.lv_jijian_yuangong, null)
            vh = ViewHolder(v)
            v.tag = vh
        } else {
            v = convertView
            vh = convertView.tag as ViewHolder
        }
        val membersBean = mlist[position]
        Myutil.settv(membersBean.work_number, vh.tvWorkNumber)
        Myutil.settv(membersBean.wu_name, vh.tvWuName)
        return v
    }

    class ViewHolder(v: View) {
        var tvWuName: TextView = v.tv_wu_name
        var tvWorkNumber: TextView = v.tv_work_number
    }
}
